package com.hundredapp.oa.domain;

import static javax.persistence.GenerationType.IDENTITY;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * OaClass entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "oa_class", catalog = "oa_demo")
public class OaClass implements java.io.Serializable {

	// Fields

	private Integer id;
	private OaUser oaUserByBishop;
	private OaUser oaUserByAssistant;
	private OaSubject oaSubject;
	private String className;
	private String classroom;
	private Integer count;
	private Integer age;
	private Integer createUserId;
	private Timestamp createTime;
	private Integer state;
	private List<OaStudent> oaStudents = new ArrayList<OaStudent>(0);
	private List<OaWorktime> oaWorktimes = new ArrayList<OaWorktime>(0);

	// Constructors

	/** default constructor */
	public OaClass() {
	}
	
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "bishop")
	public OaUser getOaUserByBishop() {
		return this.oaUserByBishop;
	}

	public void setOaUserByBishop(OaUser oaUserByBishop) {
		this.oaUserByBishop = oaUserByBishop;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "assistant")
	public OaUser getOaUserByAssistant() {
		return this.oaUserByAssistant;
	}

	public void setOaUserByAssistant(OaUser oaUserByAssistant) {
		this.oaUserByAssistant = oaUserByAssistant;
	}

	@Column(name = "class_name", length = 45)
	public String getClassName() {
		return this.className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	@Column(name = "count")
	public Integer getCount() {
		return this.count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	@Column(name = "age")
	public Integer getAge() {
		return this.age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}
	
	@Column(name = "create_user_id")
	public Integer getCreateUserId() {
		return this.createUserId;
	}

	public void setCreateUserId(Integer createUserId) {
		this.createUserId = createUserId;
	}

	@Column(name = "create_time", length = 19)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}
	
	@ManyToMany(cascade ={CascadeType.REFRESH,CascadeType.MERGE,CascadeType.PERSIST}, fetch = FetchType.LAZY)
	@JoinTable(name = "oa_student_class", catalog = "oa_demo", joinColumns = { @JoinColumn(name = "class_id", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "student_id", updatable = false) })
	public List<OaStudent> getOaStudents() {
		return this.oaStudents;
	}

	public void setOaStudents(List<OaStudent> oaStudents) {
		this.oaStudents = oaStudents;
	}
	
	@OneToMany(cascade ={CascadeType.REFRESH,CascadeType.MERGE,CascadeType.PERSIST},fetch = FetchType.LAZY, mappedBy = "oaClass")
	public List<OaWorktime> getOaWorktimes() {
		return this.oaWorktimes;
	}

	public void setOaWorktimes(List<OaWorktime> oaWorktimes) {
		this.oaWorktimes = oaWorktimes;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "subjectid")
	public OaSubject getOaSubject() {
		return oaSubject;
	}

	public void setOaSubject(OaSubject oaSubject) {
		this.oaSubject = oaSubject;
	}

	@Column(name = "classroom")
	public String getClassroom() {
		return classroom;
	}

	public void setClassroom(String classroom) {
		this.classroom = classroom;
	}

	@Column(name = "state")
	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

}